package cn.peifu.hrm.fallback;

import cn.peifu.hrm.feign.LoginFeignClient;
import cn.peifu.hrm.to.LoginMealTo;
import cn.peifu.hrm.to.Loginto;
import cn.peifu.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFallBackFactory implements FallbackFactory<LoginFeignClient> {
    @Override
    public LoginFeignClient create(Throwable throwable) {
        return new LoginFeignClient() {
            @Override
            public AjaxResult save(Loginto loginto) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("auth服务降级");
            }

            @Override
            public AjaxResult saveLoginMeal(LoginMealTo to) {
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("auth服务降级");
            }
        };
    }
}
